#ifndef _HTML_H
#define _HTML_H

const char _HTML[] PROGMEM = R"rawliteral(
<!DOCTYPE html>
<html lang="en"><head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>配置</title>
    <style>
        * {
            font-size: 16px;
        }
        body {
            margin: 0;
            padding: 0;
        }
        .panel {
            width: calc(100% - 20px);
            height: auto;
            margin: 10px;
            border-radius: 5px;
            border: 1px solid lightgray;
        }
        .row {
            width: 100%;
            padding: 5px;
        }
        .row > span {
            display: inline-block;
            width: 100%;
            margin-bottom: 3px;
        }
        .row > input, select {
            width: calc(100% - 10px);
            padding: 7px;
        }
        .row > button {
            width: calc(100% - 10px);
            padding: 7px;
            margin-top: 15px;
        }
        #msg {
            color: darkorchid;
        }
    </style>
</head>
<body>
    <div class="panel">
        <form>
            <div class="row">
                <span>WiFi名称</span>
                <input type="text" name="ssid" id="ssid">
            </div>
            <div class="row">
                <span>WiFi密码</span>
                <input type="text" name="pwd" id="pwd">
            </div>
            <div class="row">
                <span>MQTT服务器</span>
                <input type="text" name="server" id="server" value="bemfa.com">
            </div>
            <div class="row">
                <span>MQTT端口</span>
                <input type="number" name="port" id="port" value="9501">
            </div>
            <div class="row">
                <span>MQTT令牌/Token</span>
                <input type="text" name="token" id="token">
            </div>
            <div class="row">
                <span>引脚0主题</span>
                <input type="text" name="topic0" id="topic0">
            </div>
            <div class="row">
                <span>引脚2主题</span>
                <input type="text" name="topic2" id="topic2">
            </div>
            <div class="row">
                <button type="button" onclick="config()">提交</button>
            </div>
            <p id="msg"></p>
        </form>
    </div>
    <script>
        function getElement(id) {
            return document.getElementById(id).value;
        }
        function config() {
            var url = `/config?ssid=${getElement("ssid")}&pwd=${getElement("pwd")}&server=${getElement("server")}&port=${getElement("port")}&token=${getElement("token")}&topic0=${getElement("topic0")}&topic2=${getElement("topic2")}`;
            fetch(url).then(res=>res.text())
            .then((res)=>{
                document.getElementById("msg").innerText = res;
            })
            .catch(error=>{
                document.getElementById("msg").innerText = "请求失败："+error;
            });
        }
    </script>
</body></html>
)rawliteral";

#endif //_HTML_H
